#include <func.h>

int print(){
    exit(1);
}

int main()
{
    int status = 0;
    if(!fork())
    {
        printf("child : child running ,pid : %d,\n",getpid());
        int exitcode = 100;
        printf("child : exiting in 1 sec...with code %d\n",exitcode);
        exit(exitcode);
    }
    else
    {
        int exitCode;
        printf("parent :ready to execute wait()\n");
        pid_t childpid = wait(&exitCode);
        printf("parent :child pid :%d has exited\n",childpid);
        if(WIFEXITED(exitCode))
        {    
            printf("parent :child is exited with code: %d\n",WEXITSTATUS(exitCode));
            return 0;
        }
        else 
        {
            printf("parent :child crashed...");
        }
    }
    return 0;
}

